﻿// library service to get user info, folders, and images
angular.module('app.user').service('libraryService', ['dataService',
	function (dataService) {
		'use strict';
		var
			// get user data from data service
		getUserInfo = function (userId) {
			return dataService.download('User', 'Id = ' + userId.toString());
		},
		// get the list of all of the root folders for the user
		getFolders = function (userId) {
			return dataService.download('Folder', 'ParentFolderId = 0 AND UserId = ' + userId.toString());
		},
		// get all of the images for the folder
		getImagesInFolder = function (userId, folderId) {
			return dataService.download('Image', 'UserId = ' + userId.toString() + ' AND FolderId = ' + folderId.toString());
		},
		svc = {
			getImagesInFolder: getImagesInFolder,
			getUserInfo: getUserInfo,
			getFolders: getFolders
		};

		return svc;
	}]);